/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package almacen;

import java.awt.Component;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.EventObject;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JProgressBar;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import resources.local_connection;

/**
 *
 * @author pato
 */
public class verLotes extends javax.swing.JFrame {

    /**
     * Creates new form verLotes
     */
    public verLotes() {
        initComponents();
        jTable1.getColumnModel().getColumn(0).setCellRenderer(new CELL_RENDERER());
        jTable1.getColumnModel().getColumn(0).setCellEditor(new TableCellEditor() {
            @Override
            public boolean stopCellEditing() {
                return false;
            }
            @Override
            public boolean shouldSelectCell(EventObject arg0) {
                return false;
            }
            @Override
            public void removeCellEditorListener(CellEditorListener arg0) {}
            @Override
            public boolean isCellEditable(EventObject arg0) {
                 return false;
            }
            @Override
            public Object getCellEditorValue() {
                return null;
            }
            @Override
            public void cancelCellEditing() {}
            @Override
            public void addCellEditorListener(CellEditorListener arg0) {    }   
            @Override
            public Component getTableCellEditorComponent(JTable table, Object value,
                    boolean isSelected, int row, int column) {
                return null;
            }         
           

            
            
        });
        cargarDatos();
    }
    private void cargarDatos(){
        try {
            PreparedStatement ps = local_connection.getconnect().prepareStatement("select lote.cantidad,lote.fecha, sum(detalleventa.cantidad) from lote join detalleventa on detalleventa.id_producto = lote.id_producto join venta on detalleventa.folio = venta.folio where venta.fecha>lote.fecha group by lote.id_producto");
        } catch (SQLException ex) {
Almacen.logger.log(Level.SEVERE, null, ex);        }
    }
class CELL_RENDERER implements TableCellRenderer{
        @Override
        public Component getTableCellRendererComponent(JTable arg0,
                Object arg1, boolean arg2, boolean arg3, int arg4, int arg5) {
            try{
            return (JProgressBar)arg1;
            }catch (Exception ex) {Almacen.logger.log(Level.SEVERE, null, ex);}
         return (JProgressBar)arg1;
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Id", "Id Producto", "Nombre", "Fecha", "Vendidos", "Pedidos"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Float.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
  
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
